﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WPF_Drawer_Demo.Views
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void ToggleButton_Checked(object sender, RoutedEventArgs e)
        {
            // 切换到视图 1
            ChangeTemplate("FirstViewTemplate");
        }

        private void ToggleButton_Unchecked(object sender, RoutedEventArgs e)
        {
            // 切换到视图 2
            ChangeTemplate("SecondViewTemplate");
        }

        private void ChangeTemplate(string templateName)
        {
            ContentDisplay.ContentTemplate = (DataTemplate)FindResource(templateName);
        }



        private void DataTemplate_Checked(object sender, RoutedEventArgs e)
        {
            if (sender is RadioButton radioButton && radioButton.Tag != null)
            {
                string selectedTemplateKey = radioButton.Tag.ToString();
                ContentDisplay.ContentTemplate = (DataTemplate)FindResource(selectedTemplateKey);
            }
        }
    }
}
